import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int testCases = Integer.parseInt(br.readLine().trim());
		while (testCases-- != 0) {
			String str = br.readLine().trim();
			StringTokenizer sToken = new StringTokenizer(str, " ");
			
			int testNum = Integer.parseInt(sToken.nextToken());
			int n = Integer.parseInt(sToken.nextToken());
			int k = Integer.parseInt(sToken.nextToken());
			
			Long[][][] mem = new Long[n + 1][k + 1][2];
			
			long ret = getComb(n, k, 1, mem);
			ret += getComb(n, k, 0, mem);
			
			System.out.println(testNum + " " + ret);
		}
	}
	
	private static long getComb(int n, int k, int lastDigit, Long[][][] mem) {
		if(k < 0 || k > n) {
			return 0;
		}
		
	
		if(n == 0) {
			return 1;
		}
		
		if(n == 1) {
			if(k == 1) {
				if(lastDigit == 1) {
					return 1;
				} else {
					return 0;
				}
			} else {
				
				if(lastDigit == 0) {
					return 1;
				} else {
					return 0;
				}
			}
		}
		
		if(n == 2) {
			if(k == 2) {
				return 0;
			}
			if(k == 1) {
				if(lastDigit == 1) {
					return 1;
				} else {
					return 0;
				}
			} else {
				if(lastDigit == 1) {
					return 1;
				} else {
					return 2;
				}
			}
		}
		
		if(mem[n][k][lastDigit] != null) {
			return  mem[n][k][lastDigit];
		}
		
		long ret = 0;
		
		if(lastDigit == 1) {
			ret += getComb(n - 1, k - 1, 1, mem);
			ret += getComb(n - 1, k, 0, mem);
		} else {
			ret += getComb(n - 1, k, 1, mem);
			ret += getComb(n - 1, k, 0, mem);
		}
		
		mem[n][k][lastDigit] = ret;
		return ret;
	}

}
